package com.ghr.common;

import com.ghr.common.enums.ErrorCode;
import com.ghr.common.enums.ErrorDesc;
import lombok.Data;

import java.io.Serializable;

/**
 * @author Gghr
 * @version 1.0
 * @date 2022/12/18 0:39
 */

/**
 * 通用返回类
 * @param <T>
 */
@Data
public class Result<T> implements Serializable {

     private int code;

     private T data;

     private String message;

     private String description;

    public Result(int code, T data, String message, String description) {
        this.code = code;
        this.data = data;
        this.message = message;
        this.description = description;
    }

    public Result(ErrorCode errorCode, ErrorDesc errorDesc) {
        this(errorCode.getCode(), null,errorCode.getMessage(), errorDesc.getDescription());
    }

    public Result(int code, T data, String message) {
        this(code, data ,message, "");
    }

    public Result(int code, T data) {
        this(code, data ,"", "");
    }

}

